﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gedea.Model.Entities;
using Gedea.Service.Services;
using Gedea.Service;

namespace Gedea.WinForm.Forms
{
    public partial class Configuration : Form
    {
        public delegate void Deleg1();
        public delegate void Deleg2(User user);

        public Configuration()
        {
            showSplashScreen();

            InitializeComponent();
        }

        private void Configuration_Load(object sender, EventArgs e)
        {
            UserControls.CompanyControl firstUser = new UserControls.CompanyControl(new Deleg1(CloseApp), new Deleg2(AddUser), false);
            panel1.Controls.Add(firstUser);

            this.Activate();
        }

        private void CloseApp()
        {
            Application.Exit();
        }

        private void AddUser(User user)
        {
            new UserService().Add(user);
            Gedea.WinForm.Home hm = new Gedea.WinForm.Home(false);
            this.Hide();
            hm.Show();
        }

        private void showSplashScreen()
        {
            using (Waiting fsplash = new Waiting())
            {
                if (fsplash.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) this.Close();
            }
        }
    }
}
